﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace RRRSRoguelikeData
{
    public class TileData
    {
        
        public string Name;
        public string Description;
        public string ImageCharacter;
        public string Color;
        public int X; 
        public int Y;

        public TileData() 
        { 
        }

        public static TileData ReadTileDataFromXML(string filepath) 
        {
            TileData tileData = new TileData();

            try
            {
                XmlSerializer TileSerializer = new XmlSerializer(typeof(TileData));

                FileStream TileFileStream = new FileStream(filepath, FileMode.Open, FileAccess.Read);

                tileData = (TileData)TileSerializer.Deserialize(TileFileStream);
            }
            catch 
            {
                tileData.Color = "Red";
                tileData.ImageCharacter = "?";
                tileData.Name = "missing file";
                tileData.Description = "missing file: " + filepath;

            }
            return tileData;
            
        }
    }
}
